package com.fsnbigdata.domain;
import org.hibernate.validator.constraints.Length;
import org.springframework.roo.addon.javabean.annotations.RooEquals;
import org.springframework.roo.addon.javabean.annotations.RooJavaBean;
import org.springframework.roo.addon.javabean.annotations.RooToString;
import org.springframework.roo.addon.jpa.annotations.entity.RooJpaEntity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
import io.springlets.format.EntityFormat;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Basic;
import javax.persistence.Lob;
import java.util.Objects;
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;

/**
 * = OrganismSpecimen
 *
 * TODO Auto-generated class documentation
 *
 */
@RooJavaBean
@RooToString
@RooJpaEntity
@RooEquals(isJpaEntity = true)
@Entity
@EntityFormat
public class OrganismSpecimen {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @Version
    private Integer version;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @EntityFormat
    private Organism organism;

    /**
     * 采集号
     */
    @NotNull
    @Length(min = 0, max = 255,message ="采集号信息内容长度必须在0-255个字符之间")
    private String collectNumber;

    /**
     * 采集地
     */
    @Length(min = 0, max = 255,message ="采集地信息内容长度必须在0-255个字符之间")
    private String collectLocation;

    /**
     * 采集时间
     */
    @Length(min = 0, max = 255,message ="采集时间信息内容长度必须在0-255个字符之间")
    private String collectDate;

    /**
     * 采集人
     */
    @Length(min = 0, max = 255,message ="采集人信息内容长度必须在0-255个字符之间")
    private String collectPerson;

    /**
     * 采集地坐标
     */
    @Length(min = 0, max = 255,message ="采集地坐标信息内容长度必须在0-255个字符之间")
    private String collectCoordinate;

    /**
     * 标本类型
     */
    private Integer type;

    /**
     * 标本情况
     */
    @Length(min = 0, max = 255,message ="标本情况信息内容长度必须在0-255个字符之间")
    private String status;

    /**
     * 标本描述
     */
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Length(min = 0, max = 1000,message ="标本描述信息内容长度必须在0-1000个字符之间")
    private String description;

    /**
     * 保存地
     */
    @Length(min = 0, max = 255,message ="保存地信息内容长度必须在0-255个字符之间")
    private String preserveLocation;

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE = "The given Iterable of items to add can't be null!";

    /**
     * This `equals` implementation is specific for JPA entities and uses
     * the entity identifier for it, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @param obj
     * @return Boolean
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        // instanceof is false if the instance is null
        if (!(obj instanceof OrganismSpecimen)) {
            return false;
        }
        return getId() != null && Objects.equals(getId(), ((OrganismSpecimen) obj).getId());
    }

    /**
     * This `hashCode` implementation is specific for JPA entities and uses a fixed `int` value to be able
     * to identify the entity in collections after a new id is assigned to the entity, following the article in
     * https://vladmihalcea.com/2016/06/06/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
     *
     * @return Integer
     */
    public int hashCode() {
        return 31;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Long
     */
    public Long getId() {
        return this.id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Integer
     */
    public Integer getVersion() {
        return this.version;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param version
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Organism
     */
    public Organism getOrganism() {
        return this.organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param organism
     */
    public void setOrganism(Organism organism) {
        this.organism = organism;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectNumber() {
        return this.collectNumber;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectNumber
     */
    public void setCollectNumber(String collectNumber) {
        this.collectNumber = collectNumber;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectLocation() {
        return this.collectLocation;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectLocation
     */
    public void setCollectLocation(String collectLocation) {
        this.collectLocation = collectLocation;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectDate() {
        return this.collectDate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectDate
     */
    public void setCollectDate(String collectDate) {
        this.collectDate = collectDate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectPerson() {
        return this.collectPerson;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectPerson
     */
    public void setCollectPerson(String collectPerson) {
        this.collectPerson = collectPerson;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getCollectCoordinate() {
        return this.collectCoordinate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param collectCoordinate
     */
    public void setCollectCoordinate(String collectCoordinate) {
        this.collectCoordinate = collectCoordinate;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getStatus() {
        return this.status;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param status
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getDescription() {
        return this.description;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    public String getPreserveLocation() {
        return this.preserveLocation;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param preserveLocation
     */
    public void setPreserveLocation(String preserveLocation) {
        this.preserveLocation = preserveLocation;
    }

    @Override
    public String toString() {
        return "OrganismSpecimen{" +
                "id=" + id + '\'' +
                ", version=" + version + '\'' +
                ", collectNumber='" + collectNumber + '\'' +
                ", collectLocation='" + collectLocation + '\'' +
                ", collectDate='" + collectDate + '\'' +
                ", collectPerson='" + collectPerson + '\'' +
                ", collectCoordinate='" + collectCoordinate + '\'' +
                ", type=" + type +
                ", status='" + status + '\'' +
                ", description='" + description + '\'' +
                ", preserveLocation='" + preserveLocation + '\'' +
                ", ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE + '\'' +
                ", ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE + '\'' +
                '}'+super.toString();
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return String
     */
    /*public String toString1() {
        return "OrganismSpecimen {" +
                "id='" + id + '\'' +
                ", version='" + version + '\'' +
                ", collectNumber='" + collectNumber + '\'' +
                ", collectLocation='" + collectLocation + '\'' +
                ", collectDate='" + collectDate + '\'' +
                ", collectPerson='" + collectPerson + '\'' +
                ", collectCoordinate='" + collectCoordinate + '\'' +
                ", status='" + status + '\'' +
                ", description='" + description + '\'' +
                ", preserveLocation='" + preserveLocation + '\'' +
                ", ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_ADD_CANT_BE_NULL_MESSAGE + '\'' +
                ", ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE='" + ITERABLE_TO_REMOVE_CANT_BE_NULL_MESSAGE + '\'' +
                "}" + super.toString();
    }*/
}
